Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: Sound

| Previous | Chapter contents | Chapter top | Section top | Next |

Saving and Restoring Sound Component Preferences

A sound component can use the SetSoundPreference and GetSoundPreference functions to save and restore a user's preference settings.

SetSoundPreference

A sound component can use the SetSoundPreference function to have the Sound Manager store a block of preferences data in a resource file. You're most likely to use this function in a sound output device component, although other types of sound components can use it also.

pascal OSErr SetSoundPreference (OSType type, Str255 name,
                                                              Handle settings);
type
The resource type to be used to create the preferences resource.
name
The resource name to be used to create the preferences resource.
settings
A handle to the data to be stored in the preferences resource.

DESCRIPTION

The SetSoundPreference function causes the Sound Manager to attempt to create a new resource that contains preferences data for your sound component. You can use this function to maintain a structure of any format across subsequent startups of the machine. You'll retrieve the preferences data by calling the GetSoundPreference function. The data is stored in a resource with the specified type and name in a resource file in the Preferences folder in the System Folder. In general, the resource type and name should be the same as the sound component subtype and name.

The settings parameter is a handle to the preferences data you want to store. It is the responsibility of your component to allocate and initialize the block of data referenced by that handle. The Sound Manager copies the handle's data into a resource in the appropriate location. Your sound component should dispose of the handle when SetSoundPreference returns.

The format of the block of preferences data referenced by the settings parameter is defined by your sound component. It is recommended that you include a field specifying the version of the data format; this allows you to modify the format of the block of data while remaining compatible with previous formats you might have defined.

SPECIAL CONSIDERATIONS

The SetSoundPreference function is available only in versions 3.0 and later of the Sound Manager.

GetSoundPreference

A sound component can use the GetSoundPreference function to have the Sound Manager read a block of preferences data from a resource file. You'll use it to retrieve a block of preferences data you previously saved by calling SetSoundPreference .

pascal OSErr GetSoundPreference (OSType type, Str255 name,
                                                              Handle settings);
type
The resource type of the preferences resource.
name
The resource name of the preferences resource.
settings
A handle to the data in the preferences resource.

DESCRIPTION

The GetSoundPreference function retrieves the block of preferences data you previously stored in a resource by calling the SetSoundPreference function. It is the responsibility of your component to allocate the block of data referenced by the settings handle. The Sound Manager resizes the handle (if necessary) and fills it with data from the resource with the specified type and name. Your sound component should dispose of the handle once it's finished reading the data from it. You can determine the size of the handle returned by the Sound Manager by calling the Memory Manager's GetHandleSize function.

SPECIAL CONSIDERATIONS

The GetSoundPreference function is available only in versions 3.0 and later of the Sound Manager.


© 1999 Apple Computer, Inc.

| Previous | Chapter contents | Chapter top | Section top | Next |